package cn.itcast.service.impl;

import cn.itcast.dao.CourierDao;
import cn.itcast.domain.Courier;
import cn.itcast.domain.Standard;
import cn.itcast.service.CourierService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;

@Service
public class CourierServiceImpl implements CourierService{

    @Autowired
    private CourierDao courierDao;



    @Override
    public void save(Courier courier) {
        System.out.println(courier);
        courierDao.save(courier);
    }

    @Override
    public Page<Courier> findAllPage(Specification<Courier> specification, Pageable pageable) {


        Page<Courier> couriers = courierDao.findAll(specification,pageable);

        return couriers;
    }

    @Override
    public void delete(String[] ids) {
        for (String id : ids) {
            courierDao.updateDelTag(Integer.parseInt(id));
        }

    }

    @Override
    public void restore(String[] ids) {
        for (String id : ids) {
            courierDao.updateRestoreTag(Integer.parseInt(id));
        }

    }
}
